package com.clps.designPatterns.简单工厂;

import javax.xml.bind.SchemaOutputResolver;

/**
 * 餐厅流程简单藐视
 * 食品抽象,规定食品的基础属性操作
 * 鱼类,鸡肉类食品类扩展
 * 订餐流程,根据食品名称,加工指定食品的
 * 模拟客户端预订的操作
 */
public class demo01 {
    public static void main(String[] args) {
        OrderFood1 orderFood = new OrderFood1();
        orderFood.orderFood("fish") ;
        orderFood.orderFood("chicken") ;
    }
}

class OrderFood1{
    public Food1 orderFood(String foodName){
        Food1 food1 = null;
        if(foodName.equals("fish")){
            food1 = new FishFood1();
            food1.setName("黑鱼");
        } else if (foodName.equals("chicken")) {
            food1 = new CheckFood1();
            food1.setName("土鸡");
        }
        if(food1!=null){
            food1.foodMaterial();
            food1.cookFood();
            return food1;
        }else{
            return null;
        }
    }

}

abstract  class Food1{
    protected  String name;
    public  abstract  void  foodMaterial();

    public  void  cookFood(){
        System.out.println("食品烹饪"+name);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

/**
 * 材料:黑鱼一条
 */

class FishFood1 extends  Food1{

    @Override
    public void foodMaterial() {
        System.out.println("材料:黑鱼一条");
    }
}

class CheckFood1 extends  Food1{

    @Override
    public void foodMaterial() {
        System.out.println("材料:土鸡一号");
    }
}
